  # This is a basic workflow to help you get started with Actions

  name: SSH_ROLLBACK

  # Controls when the workflow will run
  on:
    # Allows you to run this workflow manually from the Actions tab
    workflow_dispatch:

  # A workflow run is made up of one or more jobs that can run sequentially or in parallel
  jobs:
    # This workflow contains a single job called "build"
    rollback:
      environment: testenv
      # The type of runner that the job will run on
      runs-on: ubuntu-latest

      # Steps represent a sequence of tasks that will be executed as part of the job
      steps:

        - name: Rollback code
          uses: appleboy/ssh-action@master
          with:
            host: ${{ vars.DEPLOY_HOST }}
            username: ${{ secrets.SSH_USER }}
            key: ${{ secrets.SSH_PRIVATE_KEY }}
            script: |
              unlink /var/www/html/current
              mv -Tf /var/www/html/previous /var/www/html/current
              cd /var/www/html/current
              sh ./rollback.sh  ${{ vars.DEPLOY_HOST }}

